package cn.iocoder.yudao.framework.business.benefit.dao;

import cn.iocoder.yudao.framework.business.basic.dao.mapper.CoreMapper;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.business.benefit.pojo.po.BenefitEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 权益保障 Mapper，由子类继承，子类标注 @{@link org.apache.ibatis.annotations.Mapper}
 *
 * @author 山野羡民
 */
//@org.apache.ibatis.annotations.Mapper
public interface BenefitMapper extends CoreMapper<BenefitEntity> {

    default List<BenefitEntity> selectListByCategoryId(Long categoryId) {
        List<BenefitEntity> list = selectList(new CoreLambdaQueryWrapper<BenefitEntity>()
                .eqIfPresent(BenefitEntity::getCategoryId, categoryId)
                .orderByAsc(BenefitEntity::getSort)
                .orderByDesc(BenefitEntity::getId));
        if (list == null) {
            list = new ArrayList<>();
        }
        return list;
    }

}
